# Maintainer: Daniel M. Capella <polyzen@archlinux.org>

pkgname=python-dkim
pkgver=1.1.3
pkgrel=1
pkgdesc='Python library that implements DKIM and ARC email signing and verification'
arch=('any')
url=https://launchpad.net/dkimpy
license=('ZLIB')
depends=('python-dnspython')
makedepends=(
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
checkdepends=('python-authres' 'python-pynacl')
optdepends=('python-aiodns' 'python-authres' 'python-pynacl')
source=("https://files.pythonhosted.org/packages/source/d/dkimpy/dkimpy-$pkgver.tar.gz")
sha256sums=('f33221951f633811176fd0f5a861f44bc23bdb5fdc2a7fa359753195401b1308')
b2sums=('179bd811725f17a89c6ef62b9295d5e0c97df9fc6257e62025262466eae79562ccb3e8088e2388ec481558c88647a646ebeb9b36afbf5d59919e14ac6f1ce0af')

build() {
  cd dkimpy-$pkgver
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd dkimpy-$pkgver
  python -m unittest dkim.tests.test_suite
}

package() {
  cd dkimpy-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/dkimpy-$pkgver.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
